package com.wdcg.fragment;

import java.util.HashMap;

import com.google.android.gms.maps.model.Marker;
import com.wdcg.R;
import com.wdcg.model.access.DwarfAccess;
import com.wdcg.model.dao.DwarfDescription;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class DwarfDescriptionFragment extends Fragment {
	
	public final static String PARAM_DWARF_ID = "DwarfID";
	private ImageView mImageView;
	private TextView mNameTextView;
	private TextView mDescriptionTextView;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		Bundle lArgs = getArguments();
		Integer lDwarfId = lArgs.getInt(PARAM_DWARF_ID);
		DwarfDescription lDwarfDescription = DwarfAccess.getDwarfDescriptionForDwarfId(lDwarfId);
		
		View v = inflater.inflate(R.layout.fragment_dwarf_description, container, false);
		
		mImageView = (ImageView) v.findViewById(R.id.dwarf_description_image);
		mImageView.setImageResource(
				getActivity().getResources()
				.getIdentifier(
						"@drawable/"+lDwarfDescription.getDwarf().getImgTitle(),
						null,
						getActivity().getPackageName()));
		
		mNameTextView = (TextView) v.findViewById(R.id.dwarf_description_name);
		mNameTextView.setText(lDwarfDescription.getName());
		
		mDescriptionTextView = (TextView) v.findViewById(R.id.dwarf_description_details);
		mDescriptionTextView.setText(lDwarfDescription.getDescription());
		
		return v;
	}
}